package com.application.Custom;

import java.util.List;

import com.application.Activity.R;
import com.application.Tree.MyHandlerInterface;
import com.application.outdoor.adapter.ThirdPartyAppInfoAdapter;


import android.app.Dialog;
import android.content.Context;
import android.content.pm.ResolveInfo;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;

public class ThirdPartyAppDialog extends Dialog implements OnItemClickListener{
	ListView lvApp;
	ThirdPartyAppInfoAdapter adapter;
	MyHandlerInterface ItemClick;
	public static Integer index=-1;
	public ThirdPartyAppDialog(Context context,String title, List<ResolveInfo> data) {
		super(context);
		setContentView(R.layout.od_third_party_dialog);
		this.setTitle(title);
		lvApp=(ListView)findViewById(R.id.lvThirdPartyApp);
		adapter=new ThirdPartyAppInfoAdapter(context, data);
		this.lvApp.setAdapter(adapter);
		lvApp.setOnItemClickListener(this);
	}
	@Override
	public void onItemClick(AdapterView<?> arg0, View arg1, int postion, long arg3) {
		if (ItemClick != null) {
			index = postion;
			ItemClick.onHandle(index);
			Toast.makeText(getContext(), "index= " + index, 1).show();
		}
		dismiss();
	}
	public void setItemClick(MyHandlerInterface itemClick) {
		ItemClick = itemClick;
	}

}
